home *** CD-ROM | disk | FTP | other *** search
- Path: news.bridge.net!news
- From: David Byrden <100101.2547@compuserve.com>
- Newsgroups: comp.lang.c++
- Subject: Default template parameter..
- Date: 16 Jan 1996 06:02:19 GMT
- Organization: self-employed
- Message-ID: <4dff1b$ias@news.bridge.net>
- NNTP-Posting-Host: ppp-mia2-69.bridge.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
-
-
- Can anyone clear up something about templates for me... here is a
- simplified version of the STL class "set" showing one of its
- constructors:
-
- template <class Key, class Compare = less<Key> >
- class set
- {
- set(const Compare& comp = Compare()) ;
- ..........
-
-
- Now, obviously the comparing class will be less<int> when you instantiate
- like this;
-
- set< int > mySet () ;
-
-
- and of course you can set it to be something else in this manner;
-
- set< int, greater<int> > mySet () ;
-
- BUT: if I omit the Compare type from the template perameter list,
- am I right in assuming the type will be deduced from the FUNCTION
- parameter list of the constructor, i.e. the default type less<Key> will
- be ignored??
-
- set< int > mySet ( greater<int> ) ;
-
- Thanks!
-
- David
-
-
-